package com.soft.base.enums;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.JSONSerializer;
import com.alibaba.fastjson.serializer.ObjectSerializer;
import com.soft.base.exception.ParamException;

import java.io.IOException;
import java.lang.reflect.Type;
/**
 * class
 *
 * @author user
 * @date 2020/06/05
 */
public class LongStringSerializer implements ObjectSerializer {
    @Override
    public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
        if (object instanceof Long) {
            serializer.out.write(JSON.toJSONString(object + ""));
        } else {
            ParamException.throwException("ValueNameSerializer.error");
        }
    }
}
